package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.NairMapper;
import com.tanhua.model.db.Nair;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

@DubboService
public class NairApiImpl implements NairApi{
    @Autowired
    private NairMapper nairMapper;
    @Override
    public List<Nair> findAll() {
        List<Nair> nairList = nairMapper.selectList(null);
        return nairList;
    }

    @Override
    public List<Integer> findSortById(Integer nairId) {
        List<Integer> sorts = new ArrayList<>();
        QueryWrapper qw = new QueryWrapper();
        qw.eq("nair_id",nairId);
        List<Nair> list = nairMapper.selectList(qw);
        for (Nair nair : list) {
            sorts.add(nair.getSort());
        }
        return sorts;
    }
}
